<template>
  <div class="personal">
    <router-link :to="'/editPersonal/'+current.id">
      <div class="profile">
        <img :src="baseurl + current.head_img" alt />
        <div class="profile-center">
          <div class="name">
            <span class="iconfont iconxingbienan"></span>{{current.nickname}}
          </div>
          <div class="time">2019-9-24</div>
        </div>
        <span class="iconfont iconjiantou1"></span>
      </div>
    </router-link>
    <mycell title='我的关注' desc='关注的用户' @click="$router.push({path:'/myFollows'})"></mycell>
    <mycell title='我的跟帖' desc='跟帖/回复'></mycell>
    <mycell title='我的收藏' desc='文章/视频' @click="$router.push({path:'/myStars'})"></mycell>
    <mycell title='设置'></mycell>
    <mybutton class="btn" @click="exitApp">退出</mybutton>
  </div>
</template>

<script>
import mycell from '@/components/mycell.vue'
import mybutton from '@/components/mybutton.vue'
import { getUserDetail } from '@/apis/users.js'
import myaxios from '@/utils/myaxios.js'
export default {
  data () {
    return {
        current:{},
        baseurl:''
    }
  },
  components: {
    mycell,mybutton
  },
  methods:{
    exitApp(){
      localStorage.removeItem('hm_toutiao_52')
      this.$router.push({name:'index'})
    }
  },
  async mounted(){
    this.baseurl = myaxios.defaults.baseURL

    let id = this.$route.params.id
    console.log(id)
    let res = await getUserDetail(id)
    console.log(res)
    if(res.data.message == '获取成功'){
      this.current = res.data.data
    }
  }
};
</script>

<style lang='less' scoped>
.personal {
  width: 100vw;
  height: 100vh;
  background-color: #eee;
}
a {
  color: #666;
}
.profile {
  display: flex;
  padding: 20px 10px;
  justify-content: space-between;
  align-items: center;
  border-bottom: 5px #ddd solid;

  img {
    width: 70 / 360 * 100vw;
    height: 70 / 360 * 100vw;
    border-radius: 50%;
  }

  .profile-center {
    flex: 1;
    padding: 0 10px;
  }

  .name {
    span {
      color: #75b9eb;
    }
  }

  .time {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
  }
}
.btn{
  margin: 20px auto 0;
  background-color: #f00;
}
</style>